<template>
  <el-dialog title="报告问题" width="500" :before-close="handleClose">
    <el-form :model="form" label-width="auto">
      <el-form-item label="问题类型">
        <el-select v-model="form.errorType" placeholder="请选择问题类型">
          <el-option label="题目描述不清" value="1" />
          <el-option label="选项有误" value="2" />
          <el-option label="系统功能异常" value="3" />
          <el-option label="其他问题" value="4" />
        </el-select>
      </el-form-item>
      <el-form-item label="问题描述">
        <el-input
          v-model="form.errorDescription"
          type="textarea"
          :rows="3"
          placeholder="请详细描述您遇到的问题..."
        />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="handleClose">取消</el-button>
        <el-button type="primary" @click="submitError"> 提交</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref, reactive } from "vue";
import { ElMessage } from "element-plus";

const dialogVisible = ref(false);
const form = reactive({
  errorType: "",
  errorDescription: "",
});

const open = () => {
  dialogVisible.value = true;
};

const handleClose = () => {
  dialogVisible.value = false;
  // Optionally reset form here
  form.errorType = "";
  form.errorDescription = "";
};

const submitError = () => {
  // Implement your submission logic here
  console.log("提交的问题:", form);
  ElMessage.success("问题已提交！");
  handleClose();
};

defineExpose({
  open,
});
</script>

<style scoped>
/* You can add custom styles here if needed */
</style>
